import { defAxios as request } from '@/utils/http'

/**
 * 部门列表 - 树结构
 * @returns
 */
export const getDeptTree = data => request({
  url: '/dept/list/tree',
  method: 'GET',
  data
})

/**
 * 部门列表 - 树结构
 * @returns
 */
export const getDeptTreeById = params => request({
  url: `/dept/list/tree/${params}`,
  method: 'GET'
})

/**
 * 根据 id 获取子部门列表
 * @returns
 */
export const getDeptList = params => request({
  url: `/dept/child/list/${params}`,
  method: 'GET'
})

/**
 * 部门信息
 * @returns
 */
export const getDeptInfo = data => request({
  url: `/dept/${data}`,
  method: 'GET'
})

/**
 * 根据部门id查询 公路
 * @returns
 */
export const getIdDept = data => request({
  url: `/channel/list/by/dept/${data}`,
  method: 'GET'
})

/**
 * 根据公路id查询 航段
 * @returns
 */
export const getIdRoad = data => request({
  url: `/leg/list/by/channel/${data}`,
  method: 'GET'
})

/**
 * 根据公路id查询 航段
 * @returns
 */
export const getIdDeptIdRoad = params => request({
  url: `/leg/list/by/channel/dept/${params.channelId}/${params.deptId}`,
  method: 'GET'
})

/**
 * 新增部门
 * @param {*} params
 * @returns
 */
export const deptAdd = data => request({
  url: '/dept/add',
  method: 'POST',
  data
})

/**
 * 删除部门
 * @param {*} data
 * @returns
 */
export const deptDel = data => request({
  url: `/dept/delete/${data}`,
  method: 'DELETE'
})

/**
 * 编辑部门
 * @param {*} params
 * @returns
 */
export const deptEdit = data => request({
  url: '/dept/edit',
  method: 'PUT',
  data
})

